﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using IScript;

namespace PanTiltCruise
{
    class AngleCruise : CruiseBase
    {
        int horizon = 0;
        int vertical = 15;
        protected override void OnCruise()
        {
            if (horizon == 360)
            {
                horizon = 0;
                if (vertical == -15) vertical = 15;
                else vertical -= 15;
            }

            GoVertical(vertical);

            Thread.Sleep(3000);
            if (horizon == 0 && vertical == 15)
                Thread.Sleep(5000);

            GoHorizon(horizon);

            Thread.Sleep(3000);
            if (horizon == 0 && vertical == 15)
                Thread.Sleep(5000);

            horizon += 30;
        }

        protected override void OnStart()
        {
            this.horizon = 0;
            this.vertical = 15;
        }

        protected override void OnStop()
        {
            this.horizon = 0;
            this.vertical = 15;
        }

        void GoHorizon(int angle)
        {
            if (this.scriptCallFucntion != null)
                this.scriptCallFucntion("GoHorizon", angle);
        }

        void GoVertical(int angle)
        {
            if (this.scriptCallFucntion != null)
                this.scriptCallFucntion("GoVertical", angle);
        }

    }
}
